<template>
	<view>
		<view class="top webkit" style="align-items: center;">
			<view class="left">
				<image src="../../../../static/cry.png" mode="" v-if="result == 'seckill_refund'"></image>
				<image src="../../../../static/car.png" mode="" v-else></image>
			</view>
			<view class="flex" style="display: flex;justify-content: space-around">
				<view class="title">
					<view v-if="result == 'seckill_refund'">订单支付失败</view>
					<view v-else-if="paytype == '3'">订单提交成功</view>
					<view v-else>订单支付成功</view>
				</view>
				<view style="margin: 0 20rpx;">
					<view v-cloak style="line-height: 60upx;">{{title}}</view>
				</view>
			</view>
		</view>
		<view class="flex" style="padding: 24upx;background: #fff;display: flex;align-items: center;">
			<view class="mid" style="margin-right: 24upx;">
				<image src="../../../../static/dingwei.png" mode="" style="width: 32upx;height: 32upx;"></image>
			</view>
			<view class="">
				<view style="color: #000;" v-cloak>{{address.province}}{{address.city}}{{address.area}}
					{{address.address}}
				</view>
				<view v-cloak style="color:#c0c0c0;">{{address.realname}}&nbsp;&nbsp;&nbsp;{{address.mobile}}</view>
			</view>
		</view>
		<view class="webkit" style="padding: 12px;background: #fff;margin-top: 10px;display: flex;align-items: center;">
			<view>实付金额</view>
			<view class="flex" style="text-align: right;color: #f55;margin-left:20rpx;" v-cloak>{{price}}</view>
		</view>
		<view class="webkit" style="padding: 24upx;margin-top: 20upx;">
			<!-- <button class="flex" style="margin-right: 12upx;background: #fff;" @click="detail">订单详情</button> -->
			<button class="flex" style="margin-left: 12upx;background: #fff;" @click="backindex">返回首页</button>
		</view>
	</view>
</template>

<script>
	import {
		order_pay_success
	} from '@/api/home.js'
	export default {
		data() {
			return {
				res: [],
				openid: "",
				orderid: "",
				result: "",
				title: '',
				paytype: "",
				price: "",
				address: []
			};
		},
		onLoad: function(e) {
			uni.showLoading()
			this.orderid = e.id
			this.result = e.result
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.order_pay_successFun();
				},
				fail: () => {
					uni.navigateTo({
						url: '/pages/login/login'
					});
				}
			});
		},
		methods: {
			async order_pay_successFun() {
				let up = {
					openid: this.openid,
					id: this.orderid,
					result: true,
					order_pay_complete: 1,
				}
				let data = await order_pay_success(up);
				this.res = data
				this.paytype = data.order.paytype
				this.address = data.address
				this.price = data.order.price
				if (this.result == 'seckill_refund') {
					this.title = "支付超时，秒杀失败，系统会自动退款，如未收到退款，请联系客服！"
				} else {
					if (this.res.address != '' && this.res.address != '0' && this.res.order.istrade ==
						'0') {
						this.title = '您的包裹整装待发'
					} else if (this.res.order.istrade != '' && this.res.order.istrade != '0') {
						this.title = '您的服务已成功预约'
					} else if (this.res.order.dispatchtype != '' && this.res.order.dispatchtype !=
						'0' && this.res.order.isverify == '0') {
						this.title = '您可以到您选择的自提点取货了'
					} else if (this.res.order.isverify != '' && this.res.order.isverify != '0') {
						this.title = '您可以到适用门店去使用了'
					} else if (this.res.order.virtual != '' && this.res.order.virtual != '0') {
						this.title = '您购买的商品已自动发货'
					} else if (this.res.order.isvirtual != '' && this.res.order.isvirtual != '0' &&
						this.res.order.virtual == '0') {
						if (this.res.order.isvirtualsend != '') {
							this.title = '您购买的商品已自动发货'
						} else {
							this.title = '您已支付成功'
						}
					}
				}
			},
			detail() {
				uni.redirectTo({
					url: '../../detail/detail?id=' + this.orderid
				});
			},
			backindex() {
				uni.switchTab({
					url: '/pages/home/home'
				})
			}
		}
	}
</script>

<style>
	.top {
		padding: 40upx 24upx;
		background: #EB2E15;
		color: #fff;
		display: flex;
	}

	.top .left image {
		width: 100upx;
		height: 100upx;
		margin: 0 24upx;
	}

	.top .flex .title view {
		font-size: 40upx;
		font-weight: 600;
		line-height: 60upx;
	}
</style>